﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IUAP;
using System.Net.Mail;

public partial class Contacto : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void BtnEnviar_Click(object sender, EventArgs e)
    {
        try
        {
            MailMessage msg = new MailMessage();
            msg.IsBodyHtml = false;
            msg.From = new MailAddress(TxtEmail.Text, TxtNombre.Text);
            msg.To.Add(new MailAddress(Globals.Settings.ContactForm.MailTo));
            if (!string.IsNullOrEmpty(Globals.Settings.ContactForm.MailCC))
                msg.CC.Add(new MailAddress(Globals.Settings.ContactForm.MailCC));
            msg.Subject = string.Format(Globals.Settings.ContactForm.MailSubject, TxtAsunto.Text);
            msg.Body = TxtMensaje.Text;
            new SmtpClient().Send(msg);
            // show a confirmation message, and reset the fields
            lblFeedbackOK.Visible = true;
            lblFeedbackKO.Visible = false;
            TxtNombre.Text = "";
            TxtEmail.Text = "";
            TxtAsunto.Text = "";
            TxtMensaje.Text = "";
        }
        catch (Exception)
        {
            lblFeedbackOK.Visible = false;
            lblFeedbackKO.Visible = true;
        }

    }
}